#![no_std]
#![no_main]
#![feature(negative_impls)]
#![feature(format_args_nl)]
#![feature(const_ptr_as_ref)]
#![feature(const_option)]
#![feature(const_mut_refs)]
#![feature(offset_of_nested)]
#![feature(offset_of_enum)]
#![feature(stdarch_aarch64_prefetch)]
#![feature(stdarch_arm_hints)]
#![feature(panic_info_message)]

extern crate alloc;

mod panic;
mod print;
pub use print::*;

use crate::{
    boot::{end_bss, kpage_end, kpage_start, phys_to_virt, start_text, MEMEND, MEMSTART},
    kalloc::kalloc_init,
    processor::set_this_processor_id,
    sched::{current::current, task::task_init},
};

pub mod boot;
pub mod drivers;
pub mod irq;
pub mod kalloc;
pub mod processor;
pub mod sched;
pub mod sync;

fn main() {
    // 设置处理器标识 id
    set_this_processor_id(0);
    // 初始化控制台
    console_init();

    println!("Welcome seL4");
    println!("phys: [{:#018x}-{:#018x}]", MEMSTART, MEMEND - 1);
    println!("virt: [{:#018x}-{:#018x}]", phys_to_virt(MEMSTART), phys_to_virt(MEMEND) - 1);
    println!("page: [{:#018x}-{:#018x}]", kpage_start(), kpage_end());
    println!("kimg: [{:#018x}-{:#018x}]", start_text(), end_bss() - 1);

    // 初始化内存分配器
    kalloc_init();
    task_init();

    let init = current();
    println!("init task => {}", init.name());
}
